package com.heyun.service.impl;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.heyun.bean.HeyunCompManage;
import com.heyun.bean.HeyunSalesPlan;
import com.heyun.dao.CompManageDao;
import com.heyun.service.CompManageService;
@Service
public class CompManageServiceImpl implements CompManageService {
	@Autowired
	private CompManageDao  compmanagedao;
	@Override
	public void saveCompManage(HeyunCompManage hcm) {
		// TODO Auto-generated method stub
		compmanagedao.saveCompManage(hcm);
	}
	@Override
	public HeyunCompManage findCompManageById(int compManageId) {
		// TODO Auto-generated method stub
		HeyunCompManage hsm=compmanagedao.findCompManageById(compManageId);
		return hsm;
	}
	@Override
	public Map<String,Object> listCompManage(int currentPage) {
		// TODO Auto-generated method stub
		
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		//获取所有竞争数据的集合
		List<HeyunCompManage> complist=compmanagedao.listCompManage();
		PageInfo<HeyunCompManage> p=new PageInfo<HeyunCompManage>(complist);
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("complist", complist);
		map.put("totalPage", p.getPages());
		
		return map;
	
	}
	@Override
	public void updateCompManageById(HeyunCompManage hcm) {
		// TODO Auto-generated method stub
		compmanagedao.updateCompManageById(hcm);
		
	}
	@Override
	public void updateCompStateById(int compManageId) {
		// TODO Auto-generated method stub
		compmanagedao.updateCompStateById(compManageId);
		
	}
	@Override
	public Map<String, Object> findCompManageByMonth(int currentPage,
			String compTime) {
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		List<HeyunCompManage> complist=compmanagedao.findCompManageByMonth(compTime);
		PageInfo<HeyunCompManage> p=new PageInfo<HeyunCompManage>(complist);
		for(HeyunCompManage hcm:complist){
			System.out.println("竞争标题是====="+hcm.getCompResultTitle());
			System.out.println("类型是====="+hcm.getCompType());
		}
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("complist", complist);
		map.put("totalPage", p.getPages());
		return map;
	
	}

}
